<script>
function userSave(){
	var sma = getCookie("Msma37");
	if (sma == undefined){
		alert("Could not finde cookie! Try to go to other page and back or try after 5 seconds!")
		return false;
	}
	var sid = localStorage.getItem("Msid37");
	if(sid == null){
		alert("Could not finde cookie! Try to logout and in or try after 5 seconds!")
		return false;
	}
	if(!pwsmd5(sid, sma)){ //compare both password inputs and if match 
		alert("Passwords do not match!")
		return false;
	}
	codeInfo();//Prepare information for sending
	return true;
}
function codeInfo(){
    var elems = document.getElementsByTagName('select'), i;
	for (i = 0; i < elems.length; i++) {//get all drop-down box values in to hidden inputs
		if(elems[i].form[elems[i].id][0].type == "hidden") elems[i].form[elems[i].id][0].value = elems[i].value;
		else elems[i].form[elems[i].id][1].value = elems[i].value;
	}
	elems = document.getElementsByTagName('input')
	for (i = 0; i < elems.length; i++) {//get all checkbox values in to hidden inputs
		if((' ' + elems[i].className + ' ').indexOf(' checkbox ') > -1) {
			if(elems[i].checked) elems[i].form[elems[i].id][1].value = "True";
			else elems[i].form[elems[i].id][1].value = "False";
		}
	}
	for (i = 0; i < elems.length; i++){
		if((' ' + elems[i].className + ' ').indexOf(' tocode ') > -1) {
			elems[i].style.color = "white"; //hide value to be more visually appealling
			elems[i].value = toCode(elems[i].value);
		}
	}
}
function pwsmd5(sid, sma){
	var elems = [document.getElementById('psw1'), document.getElementById('psw2'),document.getElementById("pswcheck")];
    if (elems[0] != undefined && elems[1] != undefined && elems[0].value != "" && elems[2] != undefined){
		if(elems[0].value != elems[1].value) return false; //password don't match
		elems[0].style.color = "white";//hide password to be more visually appealling
		elems[0].value = hex_md5(elems[0].value);
		elems[2].value = hex_md5(sid + sma + elems[0].value);
		return true;
	}
	return true;//psw1 is empty and password wont save
}
</script>
%INFO% <!--information to user-->
%FORM% <!--user data editing form-->